class MyBaseException(Exception):
    code: int = 999
    message: str = '调用方法 [{}] 出现未知异常: {} !!!'

    def __init__(self, *args):
        if args:
            self.message = self.message.format(*args)
        super().__init__(self.code, self.message)

    @property
    def get_code(self) -> dict:
        return {"code": self.code, "message": self.message}


class StudentIdException(MyBaseException):
    code: int = 601
    message: str = "学号格式不正确, 必须以YA开头+年月日+5位随机数"


class AddStudentException(MyBaseException):
    code: int = 602
    message: str = "学生[{}]学号[{}]重复，请更换学号再试"


class QueryStudentException(MyBaseException):
    code: int = 603
    message: str = "学生[{}]不存在!!!"


class QueryScoreException(MyBaseException):
    code: int = 701
    message: str = "学生[{}] 暂时无成绩!!!"


class QueryStudentCourseException(MyBaseException):
    code: int = 802
    message: str = "学生[{}] 暂无选课程!!!"


class QueryCourseException(QueryStudentCourseException):
    message: str = "没有ID {} 或名称为 {} 的课程!!!"


class CourseExistException(MyBaseException):
    code: int = 803
    message: str = "课程【{}】已存在，请重新输入!!!"


class CourseNotExistException(MyBaseException):
    code: int = 804
    message: str = "课程【{}】不存在，请重新输入!!!"


class AddCourseSuccess(MyBaseException):
    code: int = 800
    message: str = "课程【{}】添加成功!!!"


class DropCourseSuccess(MyBaseException):
    code: int = 800
    message: str = "课程【{}】删除成功!!!"
